/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
							   owned_adv_object.h

	$Header: /game/owned_adv_object.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef OWNED_ADV_OBJECT_H_INCLUDED
#define OWNED_ADV_OBJECT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <cassert>

#include "player_color.h"
#include "stationary_adventure_object.h"

class t_player;

class t_owned_adv_object : public t_stationary_adventure_object
{
public:
	// Constructor
	t_owned_adv_object( std::string const & model_name );

	virtual void			destroy();
	virtual int				get_owner_number() const;
	virtual t_player_color	get_player_color() const;
	virtual int				get_scouting_range() const;
	virtual void			initialize( t_adventure_map& map );
	virtual void			place( t_adventure_map& map, t_adv_map_point const& point );
	virtual bool			read( std::streambuf&					 stream, 
								   t_qualified_adv_object_type const& type,
								   int								 version );
	virtual void			set_owner( int player_number );
	virtual void			update_state();
	virtual bool			write( std::streambuf& stream ) const; 

protected:
	virtual int		compute_scouting_range() const;
	void			set_player_color( t_player_color new_player_color );
	void			setup_flag_color();

private:
	int 			m_owner;
	t_player_color	m_player_color; // Only used during initialization
	int				m_scouting_range;
};

inline t_owned_adv_object::t_owned_adv_object( std::string const & model_name )
						 : t_stationary_adventure_object( model_name )
{
	m_owner = -1;
	m_player_color = k_player_gray;
	m_scouting_range = 0;
}

inline int t_owned_adv_object::get_owner_number() const
{
	return m_owner;
}

inline void t_owned_adv_object::set_player_color( t_player_color new_player_color )
{
	assert( new_player_color >= 0 && new_player_color < k_player_color_count );

	// Because the player color is only used during initialization,
	// it should only be accessed before the owner number is set.
	assert( m_owner < 0 );

	m_player_color = new_player_color;
}

#endif // OWNED_ADV_OBJECT_H_INCLUDED
